package service.beanAotuWare;

import api.IMessageSayService;
import service.IOCInsertType.MessageDAO;

/**
 * ${DESCRIPTION}.
 * User: wwchen
 * DateTime: 2018-05-12 15:21
 */
public class MessageSayService implements IMessageSayService {

    private MessageDAO messageDAO;

    /**
     * 构造注入default-autowire="constructor"
     * @param messageDAO
     */
//    public MessageSayService(MessageDAO messageDAO){
//        this.messageDAO = messageDAO;
//        System.out.println("constructor succeed");
//    }
    /**
     * 根据beanName自动装配，需要在xml文件中配置default-autowire="byName"
     * 也可以根据类型自动装配，需要在xml文件中配置default-autowire="byType" 该装配方法可以不指定id
     * @param messageDAO
     */
    public void setMessageDAO(MessageDAO messageDAO){
        System.out.println("byName succeed");
        this.messageDAO = messageDAO;
    }

    @Override
    public void say(String word) {
        this.messageDAO.saveMessage("从自动装配传入的参数");
        System.out.println("自动装配成功");
    }
}
